﻿using Microsoft.EntityFrameworkCore;
using Production.DomainLib.AggregatesModel.ProcessAggregate;
using Swimj.DomainLib.SeedWork;

namespace Production.InfrastructureLib.Repositories
{
    public class ProcessRepository : IProcessRepository
    {
        private readonly ProductionDbContext _dbContext;
        public IUnitOfWork UnitOfWork => _dbContext;

        public ProcessRepository(ProductionDbContext dbContext)
        {
            _dbContext = dbContext;
        }

        public Process Add(Process process)
        {
            return _dbContext.Processes.Add(process).Entity;
        }

        public async Task<Process?> Get(int id)
        {
            return await _dbContext.Processes.FirstOrDefaultAsync(i => i.Id == id);
        }
        
    }
}